<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>添加（编辑）广告位置</title>
<link href="__PUBLIC__/admin/css/xc.min.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/css/xc.admin.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/lib/iconfont/iconfont.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/xc.js"></script> 
<script type="text/javascript" src="__PUBLIC__/admin/js/xc.admin.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/common-1.0.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/layer/layer.js"></script>
</head>

<body>
<div class="pd-20">
  <form action="" method="post" class="form form-horizontal" id="myform" enctype="multipart/form-data">
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>广告位名称：</label>
      <div class="formControls col-8">
        <input type="text" class="input-text" placeholder="请输入广告位名称" id="aname" name="aname" value="{$res.po_name}">
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>广告位宽度：</label>
      <div class="formControls col-8">
        <input type="text" class="input-text" placeholder="请输入广告位宽度" id="awidth" name="awidth" value="{$res.po_width}">
      </div>px
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>广告位高度：</label>
      <div class="formControls col-8">
        <input type="text" class="input-text" placeholder="请输入广告位高度" id="aheight" name="aheight" value="{$res.po_height}">
      </div>px
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>是否启用：</label>
      <div class="formControls col-8 skin-minimal">
        <div class="radio-box"><input type="radio" id="open1" name="open" value="1" <if condition='($res[po_open] eq 1)'>checked </if>><label for="open1">是</label></div>
        <div class="radio-box"><input type="radio" id="open2" name="open" value="0" <if condition='($res[po_open] eq 0)'>checked </if>><label for="open2">否</label></div>
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>广告位描述：</label>
      <div class="formControls col-8">
        <textarea id="adesc" name="adesc" class="textarea" placeholder="说点什么...最少输入10个字符" dragonfly="true" onKeyUp="textarealength(this,100)">{$res.po_desc}</textarea>
        <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
      </div>
    </div>
    <div class="row cl">
      <div class="col-9 col-offset-3">
        <input type="hidden" id="pid" name="pid" value="{$res.po_id}">
        <button type="button" id="sub" name="sub" class="btn btn-primary radius" onClick="checkSubmit()"><i class='Hui-iconfont'>&#xe632;</i> 保存</button>
        <input class="btn btn-default radius" type="button" onClick="layer_close();" value="取消"/>
      </div>
    </div>
  </form>
</div>
<script type="text/javascript">
//按回车件触发提交
document.onkeydown=function(event){
	var e = event || window.event || arguments.callee.caller.arguments[0];
	if(e && e.keyCode==13){ // enter 键
		checkSubmit();
	}
}; 
//提交数据
function checkSubmit()
{
	var aname= $.trim($('#aname').val());
	var awid = $.trim($('#awidth').val());
	var ahei = $.trim($('#aheight').val());
    var aopen= $('input:radio:checked').val();
	var ades = $.trim($('#adesc').val());
	if(aname == ''){
		layer.msg('广告位名称不能为空', {icon: 2});
		return false;
	}if(awid == ''){
		layer.msg('广告位置的宽度不能为空!', {icon: 2});
		return false;
	}if(!checkNum(awid)){
		layer.msg('广告位置的宽度只能填写数字!', {icon: 2});
		return false;
	}if(ahei == ''){
		layer.msg('广告位置的高度不能为空!', {icon: 2});
		return false;
	}if(!checkNum(ahei)){
		layer.msg('广告位置的高度只能填写数字!', {icon: 2});
		return false;
	}if(typeof(aopen) == "undefined"){ 
		layer.msg('是否启用状态未选择', {icon: 2});
		return false;
	}if(ades == ''){
		layer.msg('广告位描述不能为空!', {icon: 2});
		return false;
	}
	$.ajax({
		type : 'post',
		url : '__MODULE__/Ad/posiAddEdit',
		data : $("#myform").serialize(),
		dataType : 'json',
		success : function(res){
			if(res.status == 1){
				layer.msg(res.msg,{icon:1,time:2000},function(){
					// 先获取窗口索引，才能关闭窗口  
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
				});
				parent.call_back_fun('success');
			}else{
				layer.msg(res.msg, {icon: 2});
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			layer.alert('网络失败，请刷新页面后重试',{icon:2});
		}
	})
}
</script>
<!-- 单选 复选框 -->
<link href="__PUBLIC__/lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/lib/icheck/jquery.icheck.min.js"></script>
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
});
</script>
<!-- 单选 复选框 -->
</body>
</html>